#include "stdafx.h"
#include "Punch.h"
#include "Game.h"
#include "SGD Wrappers\DestroyEntityMessage.h"

CPunch::CPunch()
{
	owner = nullptr;
}


CPunch::~CPunch()
{
}

void CPunch::Update(float elapsedTime)
{
	m_IPunchTimer -= elapsedTime;
	
	if (m_IPunchTimer < 0)
	{
		DestroyEntityMessage *d = new DestroyEntityMessage{ this };
		d->QueueMessage();
		d = nullptr;
	}

}


void	CPunch::Render(void)
{
	SGD::GraphicsManager* pGraphics = SGD::GraphicsManager::GetInstance();
	pGraphics->DrawRectangle({ SGD::Point{ (m_ptPosition.x - Game::GetInstance()->GetCameraPos().x), (m_ptPosition.y - Game::GetInstance()->GetCameraPos().y) },
		m_szSize * 2 }, SGD::Color{ 255, 175, 0 }, { 0, 0, 0 }, 3);
}

SGD::Rectangle CPunch::GetRect(void) const
{
	return SGD::Rectangle{ m_ptPosition, m_szSize *2};
}

void CPunch::SetOwner(Entity* o)
{
	if (o != nullptr)
		o->Release();

	owner = o;

	if (o != nullptr)
		owner->AddRef();
}

void CPunch::HandleCollision(const Entity* pOther)
{

}